//Top level entity of VGA_test
//Author:Liuhao
//Date:03,31.2018

/********************************************************************/
//module & IO declaratioi

module	VGA_test(
	ext_clk,
	ext_rst,

	VGA,
	VGA_HS,
	VGA_VS,
	
	led_out
);

input	ext_clk;
input	ext_rst;
	
output [15:0] VGA;
output	VGA_HS;
output	VGA_VS;
output	led_out;

/******************************************************/
wire	sys_rst_n;

wire	sys_clk_130m;
wire	sys_clk_65m;
wire	sys_clk_50m;
wire	sys_clk_25m;

wire	[15:0]	VGA_r;
wire	[12:0]	Hcnt;
wire	[12:0]	Vcnt;

/******************************************************/
//instance of sys_ctl, including pll and sync of rst
sys_ctl	sys_ctl_inst(
	.ext_clk(ext_clk),
	.ext_rst(ext_rst),

	.sys_clk_130m(sys_clk_130m),
	.sys_clk_65m(sys_clk_65m),
	.sys_clk_50m(sys_clk_50m),
	.sys_clk_25m(sys_clk_25m),
	.sys_rst_n(sys_rst_n)
);

/******************************************************/
//instance of VGA_basemod
VGA_basemod	VGA_basemod_inst(
	.sys_rst_n(sys_rst_n),
	.VGA_clk(sys_clk_130m),

	.VGA_r(VGA_r),
	.VGA_Hcnt(Hcnt),
	.VGA_Vcnt(Vcnt),

	.VGA(VGA),
	.VGA_H(VGA_HS),
	.VGA_V(VGA_VS)
);

/******************************************************/
//instance of VGA_ctl
VGA_ctl	VGA_ctl_inst(
	.sys_rst_n(sys_rst_n),
	.sys_clk(sys_clk_130m),

	.Hcnt(Hcnt),
	.Vcnt(Vcnt),
	.VGA(VGA_r)
);

/******************************************************/
//instance of LED
LED_ctl	LED_ctl_inst(
	.sys_clk(sys_clk_50m),
	.sys_rst_n(sys_rst_n),
	.LED(led_out)
);


endmodule
/********************************************************************/
